<template>
  <div class="page-style">
    <tabar-btn @reloadFun="reloadFun" />
    <brand-tab :brand-list="brand_list" @reloadFun="reloadFun" />
    <pagination :total="total" @pagination="pagination" />
  </div>
</template>

<script>
import tabarBtn from './components/brand/btn-tabar'
import brandTab from './components/brand/bran-tab'
import pagination from '@/components/Pagination'
import { getBrandList } from '@/api/brand'
export default {
  components: {
    tabarBtn,
    brandTab,
    pagination
  },
  data() {
    return {
      p: 1,
      num: 10,
      status: 1,
      brand_name: '',
      brand_login_name: '',
      total: 0,
      brand_list: []
    }
  },
  created() {
    this.getBrandList()
  },
  methods: {
    getBrandList() {
      const data = {
        p: this.p,
        num: this.num,
        status: this.status,
        brand_name: this.brand_name,
        brand_login_name: this.brand_login_name
      }
      getBrandList(data).then(res => {
        console.log(res)
        if (res.list.length) {
          this.total = Number(res.count)
          this.brand_list = res.list
        }
      })
    },
    pagination(val) {
      this.p = val.page
      this.num = val.limit
      this.getBrandList()
    },
    reloadFun() {
      this.getBrandList()
    }
  }
}
</script>

<style lang="scss" scoped>
</style>
